/***********************************************************************************************************************************
 * Name:	Drop_Recovery.sql
 * Author:	Frank Figearo (frank.figearo@us.bbaaviation.com|frank@sqlnerd.me)
 * Summary:	Drop databases that are in RECOVERY_PENDING.
 */
SET IMPLICIT_TRANSACTIONS OFF; WHILE 0 < @@TRANCOUNT ROLLBACK;
GO
DECLARE @tsql VARCHAR(MAX) = '';
SELECT  @tsql+= 'DROP DATABASE [' + name + '];GO' FROM sys.databases WHERE [state] = 3;
EXECUTE(@tsql);
GO